//
//  QDNavigationController.m
//  simulateQuickDoctor
//
//  Created by 梁家伟 on 17/3/22.
//  Copyright © 2017年 PipiXia. All rights reserved.
//

#import "QDNavigationController.h"

@interface QDNavigationController ()

@end

@implementation QDNavigationController

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.
    [self setupUI];
}

- (void)setupUI{
    //设置透明度
    self.navigationBar.translucent = NO;
    
    self.navigationBar.tintColor = [UIColor whiteColor];
    
    [self.navigationBar setBackgroundImage:[UIImage new] forBarMetrics:UIBarMetricsDefault];
    
    self.navigationBar.barTintColor = PPColor;
    
    //设置导航标题颜色
    [self.navigationBar setTitleTextAttributes:@{                                              NSForegroundColorAttributeName:[UIColor whiteColor]}];
    
    
    //清空导航条自带的图片
    [self.navigationBar setBackgroundImage:[UIImage new] forBarMetrics:UIBarMetricsDefault];
    //清空导航条自带的阴影
    self.navigationBar.shadowImage = [UIImage new];
    
}



- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}


//重写系统的push（跳转下一控制器入栈）方法
- (void)pushViewController:(UIViewController*)viewController animated:(BOOL)animated
{
    //设置目标控制器隐藏选项卡
    //当不是栈底控制器时隐藏子控制器的tabBar
    if(self.childViewControllers.count>0) {
        //不是栈底控制器，就是子控制器
        viewController.hidesBottomBarWhenPushed=YES;
        //设置子控制器左上角的按钮
        UIBarButtonItem* barBtn = [[UIBarButtonItem alloc]initWithTitle:@"返回" style:UIBarButtonItemStylePlain target:self action:@selector(popBack)];;
        viewController.navigationItem.leftBarButtonItem = barBtn;

    }
    [super pushViewController:viewController animated:YES];

}

- (void)popBack{
    [self popViewControllerAnimated:YES];
}
/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
